/*
  频道API
*/
import request from '@/utils/request.js'

// 获取频道数据（用户的频道列表）
export const getChannles = () => {
  return request({
    method: 'get',
    url: 'app/v1_0/user/channels'
  })
}
// 获取频道对应的文章列表
export const getArticles = (data) => {
  return request({
    method: 'get',
    url: 'app/v1_1/articles',
    params: data
  })
}
// 不感兴趣的文章
export const disLike = (id) => {
  return request({
    method: 'post',
    url: 'app/v1_0/article/dislikes',
    data: {
      target: id
    }
  })
}
// 举报文章
export const report = (data) => {
  return request({
    method: 'post',
    url: 'app/v1_0/article/reports',
    data: data
  })
}
// 获取所有频道列表
export const getAllChannels = () => {
  return request({
    method: 'get',
    url: 'app/v1_0/channels'
  })
}
// 删除我的频道
export const deleteChannel = (channelId) => {
  return request({
    method: 'delete',
    url: 'app/v1_0/user/channels/' + channelId
  })
}
// 添加频道
export const addChannel = (orderChannels) => {
  return request({
    method: 'put',
    url: 'app/v1_0/user/channels',
    data: {
      channels: orderChannels
    }
  })
}
// 根据关键字获取相应内容
export const changeContent = (q) => {
  return request({
    method: 'get',
    url: 'app/v1_0/suggestion',
    params: {
      q
    }
  })
}
// 更加关键字搜索列表
export const searchArticles = (options) => {
  return request({
    method: 'get',
    url: 'app/v1_0/search',
    params: {
      // 当前的页码
      page: options.page,
      // 每页的条数
      per_page: options.perPage,
      // 搜索的关键字
      q: options.q
    }
  })
}
